package com.thd.springboottest.jvmoptimization.controller;

import com.thd.springboottest.jvmoptimization.dto.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/test")
public class TestController {
    public static List<User> list = new ArrayList<User>();

    // 内存溢出的方法
    @RequestMapping("/createUser/{count}")
    @ResponseBody
    public String createUser(@PathVariable Integer count){
        System.out.println("createUser");
        int i = 0 ;
        while (i < count){
            list.add(new User());
            i++;
        }
        return "SUCCESS";
    }

    // 内存溢出的方法2
    @RequestMapping("/increase/{count}")
    @ResponseBody
    public String increase(@PathVariable Integer count){
        System.out.println("increase");
        User u = new User();
        u.increase(count);
        return "SUCCESS";
    }


}
